/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.openbrew.openbrewrf;

import com.openbrew.openbrewrf.views.POSSupplyView;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author dchapman
 */
@Entity
@Table(name = "CommonBrewSupplies")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CommonBrewSupplies.findAll", query = "SELECT c FROM CommonBrewSupplies c"),
    @NamedQuery(name = "CommonBrewSupplies.findByCbsid", query = "SELECT c FROM CommonBrewSupplies c WHERE c.cbsid = :cbsid"),
    @NamedQuery(name = "CommonBrewSupplies.findByAmount", query = "SELECT c FROM CommonBrewSupplies c WHERE c.amount = :amount"),
    @NamedQuery(name = "CommonBrewSupplies.findByUnits", query = "SELECT c FROM CommonBrewSupplies c WHERE c.units = :units")})
public class CommonBrewSupplies implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "CBSID")
    private Integer cbsid;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Amount")
    private float amount;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 20)
    @Column(name = "Units")
    private String units;
    @Basic(optional = false)
    @NotNull
    @Column(name = "BoilTime")
    private int boilTime;
    @JoinColumn(name = "SupplyID", referencedColumnName = "SupID", nullable=true)
    @ManyToOne(optional = true)
    private POSSupplyView supplyID;

    public CommonBrewSupplies() {
    }

    public CommonBrewSupplies(Integer cbsid) {
        this.cbsid = cbsid;
    }

    public CommonBrewSupplies(Integer cbsid, float amount, String units, int boilTime) {
        this.cbsid = cbsid;
        this.amount = amount;
        this.units = units;
        this.boilTime = boilTime;
    }

    public Integer getCbsid() {
        return cbsid;
    }

    public void setCbsid(Integer cbsid) {
        this.cbsid = cbsid;
    }

    public POSSupplyView getSupplyID() {
        return supplyID;
    }

    public void setSupplyID(POSSupplyView supplyID) {
        this.supplyID = supplyID;
    }

    public float getAmount() {
        return amount;
    }

    public void setAmount(float amount) {
        this.amount = amount;
    }

    public String getUnits() {
        return units;
    }

    public void setUnits(String units) {
        this.units = units;
    }

    public int getBoilTime() {
        return boilTime;
    }

    public void setBoilTime(int boilTime) {
        this.boilTime = boilTime;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cbsid != null ? cbsid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CommonBrewSupplies)) {
            return false;
        }
        CommonBrewSupplies other = (CommonBrewSupplies) object;
        if ((this.cbsid == null && other.cbsid != null) || (this.cbsid != null && !this.cbsid.equals(other.cbsid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.CommonBrewSupplies[ cbsid=" + cbsid + " ]";
    }
    
}
